package com.lcq.practice.springboot.universal.demo.test_transaciton;

import com.lcq.practice.springboot.universal.demo.commmon.UserPo;
import com.lcq.practice.springboot.universal.demo.test_transaciton.mapper.UserTransMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @ClassName UserTransService
 * @Description
 * @Author lichuanqi
 * @Date 2022/2/14 14:28
 * @Version 1.0
 **/
@Service
public class UserTransService {
    @Resource
    private UserTransMapper userTransMapper;

    @Transactional
    public void test(){
        UserPo userPo = userTransMapper.selectUser("1");
        userPo.setName("test1723");
        userTransMapper.updateUserName(userPo);
        int  a = 1/0;
        userPo.setAge(1723);
        userTransMapper.updateUserAge(userPo);
    }


    public void test2(){
        UserPo userPo = userTransMapper.selectUser("1");
        System.out.println(userPo);
    }
}
